<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <!-- form结构 -->
    <form>
      <input type="text" name="username" placeholder="请输入用户名" /><br />
      <input type="password" name="password" placeholder="请输入密码" /><br />
      <button type="submit">登录</button>
    </form>
    <!-- 引入axios -->
    <script src="./聊天机器人/lib/axios.js"></script>
    <script>
      //1.先获取dom
      const form = document.querySelector('form')
      form.addEventListener('submit' ,async function(e) {
         e.preventDefault()
         const arr = new FormData(this)
      const data =  await  axios({
        url : 'http://ajax-api.itheima.net/api/data',
        method : 'POST',
        arr
      })
      })
    //  const form = document.querySelector('form')
    //   form.addEventListener('submit' , function(e){
    //     e.preventDefault()
    //     const arr = new FormData(this)
    //     axios({
    //       url : 'http://ajax-api.itheima.net/api/data',
    //       method : 'POST',
    //       arr
    //     }).then(({data : res})=>{
    //       console.log(res);
    //     })
    //   })
    </script>
  </body>
</html>
